require 'DBI'

class XiangXiangDb
  def all_products()
    products = []
    conn = DBI.connect('DBI:ODBC:xiangxiang', '', '')
    sth = conn.execute("select BigClassName,SmallClassName,Title,EnTitle,Spec,Memo,DefaultPicUrl,tui from Product")
    sth.fetch_hash do |row|
      product = Product.new
      product.category=row['BigClassName']
      product.sub_category=row['SmallClassName']
      product.name=row['Title']
      product.no=row['EnTitle']
      product.color=row['Spec']
      product.price=row['Memo']
      product.pic=row['DefaultPicUrl']
      product.content= row['tui']
      products << product
    end
    sth.finish
    products
  end
end
